﻿using System;
using System.Collections.Generic;
using System.Text;

namespace StockTrader.BusinessService.DataContract.HnxInfo
{
    public class HnxDealData : IComparable
    {
        public decimal DealId { get; set; }
        public string OrderNo { get; set; }
        public string OrderConfirmNo { set; get; }
        public string CoOrderNo { get; set; }
        public DateTime DealDate { get; set; }
        public string DealTime { get; set; }
        public decimal DealPrice { get; set; }
        public decimal DealQtty { get; set; }
        public string AccountNo { get; set; }
        public string CoAccountNo { get; set; }
        public int CoBrokerId { get; set; }
        public long TimeStamp {set;get;}

        public HnxDealData() { }
        public HnxDealData(decimal id, string no, string confirm, string cono, DateTime date, string time, decimal price, decimal qtty, string accno, string coaccno, decimal cobrokerid)
        {
            DealId = id;
            OrderNo = no;
            OrderConfirmNo = confirm;
            CoOrderNo = cono;
            DealDate = date;
            DealTime = time;
            DealPrice = price;
            DealQtty = qtty;
            CoAccountNo = coaccno;
            AccountNo = accno;
            CoBrokerId = Convert.ToInt32(cobrokerid);
            TimeStamp = DateTime.Now.Ticks;
        }

        public HnxDealData(decimal id, string no, string confirm, string cono, DateTime date, string time, decimal price, decimal qtty, string accno, string coaccno, int cobrokerid, long timestamp)
        {
            DealId = id;
            OrderNo = no;
            OrderConfirmNo = confirm;
            CoOrderNo = cono;
            DealDate = date;
            DealTime = time;
            DealPrice = price;
            DealQtty = qtty;
            AccountNo = accno;
            CoAccountNo = coaccno;
            CoBrokerId = cobrokerid;
            TimeStamp = timestamp;
        }


        #region IComparable Members

        public int CompareTo(object obj)
        {
            if ((DealId - ((HnxDealData)obj).DealId).Equals(0))
                return DealTime.CompareTo(((HnxDealData)obj).DealTime);
            else
                return DealId.CompareTo(((HnxDealData)obj).DealId);
        }

        public override bool Equals(object obj)
        {
            if (DealId.Equals(((HnxDealData)obj).DealId))
                return DealTime.Equals(((HnxDealData)obj).DealTime);
            else
                return DealId.Equals(((HnxDealData)obj).DealId);
        }

        #endregion
    }
}
